package cn.iocoder.yudao.module.member.dal.mysql.faceanalyseresult;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.faceanalyserequest.FaceanalyseRequestDO;
import cn.iocoder.yudao.module.member.dal.dataobject.faceanalyseresult.FaceanalyseResultDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.faceanalyseresult.vo.*;

/**
 * 会员皮肤状态分析结果 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface FaceanalyseResultMapper extends BaseMapperX<FaceanalyseResultDO> {

    default PageResult<FaceanalyseResultRespVO> selectPage(FaceanalyseResultPageReqVO reqVO) {
        MPJLambdaWrapperX<FaceanalyseResultDO> query = new MPJLambdaWrapperX<>();
        query.selectAll(FaceanalyseResultDO.class);
        query.eqIfPresent(FaceanalyseResultDO::getUserId, reqVO.getUserId())
                .eqIfPresent(FaceanalyseResultDO::getRequestOwnId, reqVO.getRequestOwnId())
                .eqIfPresent(FaceanalyseResultDO::getRequestId, reqVO.getRequestId())
                .eqIfPresent(FaceanalyseResultDO::getLeftSideResult, reqVO.getLeftSideResult())
                .eqIfPresent(FaceanalyseResultDO::getRightSideResult, reqVO.getRightSideResult())
                .eqIfPresent(FaceanalyseResultDO::getFaceRectangle, reqVO.getFaceRectangle())
                .eqIfPresent(FaceanalyseResultDO::getTimeUsed, reqVO.getTimeUsed())
                .eqIfPresent(FaceanalyseResultDO::getErrorMessage, reqVO.getErrorMessage())
                .eqIfPresent(FaceanalyseResultDO::getMark, reqVO.getMark())
                .betweenIfPresent(FaceanalyseResultDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FaceanalyseResultDO::getId);
        query.select(FaceanalyseRequestDO::getImageUrl).leftJoin(FaceanalyseRequestDO.class, FaceanalyseRequestDO::getId, FaceanalyseResultDO::getRequestOwnId);
        return selectJoinPage(reqVO, FaceanalyseResultRespVO.class, query);
    }

}